/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.core.api.ext;

/**
 * @author Tacoma Four
 */
public interface IAdapterManager
{
    /**
     * Adapts this object to a different type of object represented by the parameters. This is a very common Eclipse
     * design pattern that has proven its mettle and has been included in the framework for future expansion.
     *
     * @param adaptableObject Object to adapt to
     * @param adapterType     Expected interface to adapt to
     * @return Adapted object, or null if the adaption couldn't be made
     */
    Object getAdapter(Object adaptableObject, Class adapterType);

    /**
     * Registers an adaptor factory for the adaptable class.
     *
     * @param factory   Factory that can perform the adaptation
     * @param adaptable Class that is adaptable
     */
    void registerAdapter(IAdapterFactory factory, Class adaptable);

    /**
     * Unregisters an adapter factory.
     *
     * @param factory Factory to unregister
     */
    void unregisterAdapter(IAdapterFactory factory);

    /**
     * Unregisters a specific adapatation.
     *
     * @param factory   Factory that was able to perform the given adaptation.
     * @param adaptable Class that was adaptable
     */
    void unregisterAdapter(IAdapterFactory factory, Class adaptable);
}
